from sqlalchemy import TEXT, ForeignKey, String
from sqlalchemy.orm import Mapped, mapped_column, relationship

from .base import TimedBaseModel


class CalendarTask(TimedBaseModel):
    __tablename__ = "calendar_task"
    __mapper_args__ = {"eager_defaults": True}

    id: Mapped[int] = mapped_column(primary_key=True)
    day: Mapped[int]
    task_text_ru: Mapped[str] = mapped_column(TEXT)
    task_text_en: Mapped[str] = mapped_column(TEXT)
    task_text_uk: Mapped[str] = mapped_column(TEXT)
    media_filename: Mapped[str | None] = mapped_column(String(255))
    calendar = relationship("Calendar", back_populates="tasks")
    calendar_id: Mapped[int] = mapped_column(ForeignKey("calendar.id"))

    def __repr__(self):
        return f"<Задача №{self.id}>"

    def __str__(self):
        return self.__repr__()
